package com.mogist.hqc.module.main.presenter

import com.mogist.hqc.entitys.BaseResponse
import com.mogist.hqc.entitys.response.MainTypeItemVo
import com.mogist.hqc.module.main.contract.SearchContract
import com.mogist.hqc.mvp.HttpDto
import com.mogist.hqc.mvp._PresenterImpl
import com.mogist.hqc.util.Constant
import talex.zsw.basecore.util.JsonTool
import talex.zsw.basecore.view.other.RxToast

/**
 * 作用：搜索
 * 作者：赵小白 email:vvtale@gmail.com  
 * 修改人：
 * 修改时间：
 * 修改备注：
 */
class SearchPresenter(view: SearchContract.View) : _PresenterImpl<SearchContract.View, BaseResponse>(
        view), SearchContract.Presenter
{
    override fun requestSuccess(response: BaseResponse, http: HttpDto)
    {
        when (http.url)
        {
            Constant.TYPE_LIST ->
            {
                mView.disDialog()
                if (response.success)
                {
                    val vo = JsonTool.getObject(response.content, MainTypeItemVo::class.java)
                    mView.bindTypes(vo)
                }
                else
                {
                    RxToast.error("搜索失败，" + response.message)
                }
            }
        }
    }
}